package com.kedacom.ctsp.authority.emuns;

import com.kedacom.ctsp.lang.StringUtil;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author sunchenjie
 * @date 2017/12/26 0026
 */
public enum SexEnum {

    // 女
    FEMALE(StringUtil.format("auth.person.sex.female")),
    // 男
    MALE(StringUtil.format("auth.person.sex.male"));

    @Getter
    private String value;


    SexEnum(String value) {
        this.value = value;
    }

    public static Byte getIndexByValue(String value) {
        if (StringUtils.isBlank(value)) {
            return -1;
        }
        SexEnum[] values = SexEnum.values();
        for (SexEnum s : values) {
            if (value.equalsIgnoreCase(s.getValue())) {
                return (byte) s.ordinal();
            }
        }
        return -1;
    }

}
